package com.jdcjk.chat;

import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.roster.RosterListener;
import org.jxmpp.util.XmppStringUtils;

import java.util.Collection;

/**
 * Created by dong on 2016/8/4.
 * 好友监听器
 */
public class OpenFireRosterListener implements RosterListener {
    @Override
    public void entriesAdded(Collection<String> addresses) {

    }

    @Override
    public void entriesUpdated(Collection<String> addresses) {

    }

    @Override
    public void entriesDeleted(Collection<String> addresses) {

    }

    @Override
    public void presenceChanged(Presence presence) {
        if (presence.isAvailable()) {
            onRosterPresenceChanged(presence, true);
        } else if (presence.getType() == Presence.Type.unavailable) {
            onRosterPresenceChanged(presence, false);
        }
    }

    private void onRosterPresenceChanged(Presence presence, boolean isAvailable) {
        String phone = XmppStringUtils.parseLocalpart(presence.getFrom());
        if (!phone.equals("servicer")) {
        }
    }
}
